﻿app.controller('LoginController', ['$scope', '$http', function ($scope, $http) {
    $scope.processLogin = function () {
        $http({
            url: '/Token',
            contentType: 'application/x-www-form-urlencoded',
            data: 'username=' + $scope.email + '&password=' + $scope.password + '&grant_type=password',
            method: 'POST'
        }).success(function (data) {
            var token = data.access_token;
            sessionStorage.setItem('role', data.role);
            sessionStorage.setItem('token', token);
            alert(token);
        });
    }
}]);